package com.example.leetcode;

import java.util.HashSet;
import java.util.Set;

public class LengSubstring {
    public static int sumStr(String nums){
        if (nums==null||nums.length()==0){
            return 0;
        }
        Set<Character> set=new HashSet<>();
        int right=0;
        int max=0;
        for (int i=0;i<nums.length();i++){
            while (right<nums.length()&&!set.contains(nums.charAt(right))){
                set.add(nums.charAt(right++));
                max=Math.max(max,right-i);
            }
            set.remove(nums.charAt(i));
        }
        return max;
    }

    public static void main(String[] args) {
        String s ="abcdabv";
        System.out.println(sumStr(s));
    }
}
